<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>信息完善</title>
</head>
<body>
<h3>请完善您的信息</h3>
<form action="" onSubmit="return nullcheck()" name="form1">
姓名：<input type="text" name="name" onblur="namecheck()" onclick="nameprompt()">
<p id="nameenterprompt" style="color:blue;display:none">输入长度不超过10的字符</p>
<p id="namenull" style="color:red;display:none">姓名不能为空</p>
<p id="namelength" style="color:red;display:none">姓名长度超过限制</p>
<br>
性别：<input type="radio" name="sex">男
&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="sex">女
<br>
E-mail：<input type="text" name="email" onblur="emailcheck()" onclick="emailprompt()">
<p id="emailenterprompt" style="color:blue;display:none">输入正确的E-mail地址</p>
<p id="emailnull" style="color:red;display:none">E-mail不能为空</p>
<p id="emailformat" style="color:red;display:none">E-mail格式不正确</p>
<br>
爱好：<br>
运动<input type="checkbox" name="hobbies" value="运动">&nbsp;&nbsp;&nbsp;&nbsp;
音乐<input type="checkbox" name="hobbies" value="音乐">&nbsp;&nbsp;&nbsp;&nbsp;
美食<input type="checkbox" name="hobbies" value="美食">&nbsp;&nbsp;&nbsp;&nbsp;
其他<input type="checkbox" name="hobbies" value="其他"><br>
<input type="submit" value="提交">
</form>
<script type="text/javascript">
function emailprompt(){
	emailnull.style.display="none";
	emailformat.style.display="none";
	emailenterprompt.style.display="inline";
}
function Isyx(yx){
	 var reyx= /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	 return(reyx.test(yx));
	}
function emailcheck(){
	emailnull.style.display="none";
	emailformat.style.display="none";
	emailenterprompt.style.display="none";
	if(form1.email.value==""){
		emailnull.style.display="inline";
	}else{
		emailnull.style.display="none";
		if(!Isyx(form1.email.value)){
			emailformat.style.display="inline";
		}else{
			emailformat.style.display="none";
		}
	}
}
function nameprompt(){
	namenull.style.display="none";
	namelength.style.display="none";
	nameenterprompt.style.display="inline";
}
function namecheck(){
	namenull.style.display="none";
	namelength.style.display="none";
	nameenterprompt.style.display="none";
	if(form1.name.value==""){
		namenull.style.display="inline";
	}else{
		namenull.style.display="none";
	}
	if(form1.name.value.length>10){
		namelength.style.display="inline";
	}else{
		namelength.style.display="none";
	}
}
function nullcheck(){
	if(form1.name.value==""){
		alert("姓名不能为空！");
		return false;
	}else{
		if(form1.sex.value==null){
			alert("性别不能为空！");
			return false;
		}else{
			if(form1.email.value==""){
				alert("E-mail不能为空！");
				return false;
			}else if(!Isyx(form1.email.value)){
				alert("E-mail格式不正确！");
				return false;
			}else{
				if(form1.hobbies.value==nulll){
					alert("爱好不能为空！");
					return false;
				}else{
					return true;
				}
			}
		}
	}
}
</script>
</body>
</html>